class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-10-19",
      revision: "0a3e0862c8c1910bea1fdf805a7915b1ffec8197"
  version "2021-10-19"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "b174b5f476f1e902b57c8633452ec10e300535f0cb51a5e677e9c95e3a93340e"
    sha256 cellar: :any_skip_relocation, big_sur:       "2734fc976c204a4a148581a0736f12a9788c89521a1682451f850bb02845c096"
    sha256 cellar: :any_skip_relocation, catalina:      "2de61a560dba35ac4854f0e2040fb87418ee18b7f669443aec733d1e802b0756"
    sha256 cellar: :any_skip_relocation, mojave:        "30f531b68153309d9fccb1670da7da75bef153df4a4da895653c094fa1140d9e"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "dc473eb2ff1a3de9edfe06b0639a29ef98df017e314c4baaea6a57b05eb3bb0c"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
